package cn.labbook.bluetooth.controller.v2;

import cn.labbook.bluetooth.controller.AbstractController;
import cn.labbook.bluetooth.pojo.dto.UploadDTO;
import cn.labbook.bluetooth.util.file.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: zhangyang
 * @Date: 2023/4/24 13:41
 * @Desc: 文件上传 controller
 */
@Controller
@RequestMapping("/v2/upload")
public class V2UploadController extends AbstractController {

    @Autowired
    private FileUtils fileUtils;


    @ResponseBody
    @RequestMapping(value = "/uploadSingle", method = RequestMethod.POST)
    public Object uploadSingle(@RequestParam(value = "file") MultipartFile file) {
        UploadDTO dto = fileUtils.uploadSingle(file);
        return success(dto);
    }

}
